const { defineConfig } = require('@vue/cli-service')
const path = require('path')

module.exports = defineConfig({
  transpileDependencies: true,
  
  // 根据环境配置基础URL
  publicPath: process.env.NODE_ENV === 'production' ? '/' : '/',
  
  // 开发服务器配置
  devServer: {
    port: 8080,
    proxy: {
      [process.env.VUE_APP_BASE_API]: {
        target: process.env.VUE_APP_BASE_URL,
        changeOrigin: true,
        pathRewrite: {
          ['^' + process.env.VUE_APP_BASE_API]: ''
        }
      }
    }
  },

  configureWebpack: {
    resolve: {
      fallback: {
        path: false
      }
    }
  },

  css: {
    loaderOptions: {
      scss: {
        additionalData: `
          @import "@/assets/styles/index.scss";
        `
      }
    }
  }
})
